package com.limf.demo.nettyRpc;

import com.limf.demo.nettyRpc.consumer.ClientBootstrap;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * 用于处理请求数据
 */
public class HelloServerHandler extends ChannelInboundHandlerAdapter {

	public void channelRead(ChannelHandlerContext ctx, Object msg) {
		
		if(msg.toString().startsWith(ClientBootstrap.providerName)) {
			
			String result = new HelloServiceImpl()
					.hello(msg.toString().substring(msg.toString().lastIndexOf("#")+1));
			ctx.writeAndFlush(result);
		}
		
		
	}

}
